package com.leyou.page.listener;

import com.leyou.page.service.PageService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.leyou.common.constants.RocketMQConstants.CONSUMER.SECKILL_BEGIN_CONSUMER;
import static com.leyou.common.constants.RocketMQConstants.TAGS.SECKILL_ORDER_TAGS;
import static com.leyou.common.constants.RocketMQConstants.TOPIC.SECKILL_TOPIC_NAME;

@Component
@RocketMQMessageListener(consumerGroup = SECKILL_BEGIN_CONSUMER,topic = SECKILL_TOPIC_NAME,selectorExpression = SECKILL_ORDER_TAGS)
public class CreateSeckillPageListener implements RocketMQListener<String> {

    @Autowired
    private PageService pageService;

    @Override
    public void onMessage(String nowDate) {
        pageService.createSeckillPage(nowDate);
        System.out.println("秒杀商品的静态页面已完成");
    }
}
